--- share/mk/bsd.compiler.mk.orig
+++ share/mk/bsd.compiler.mk
@@ -168,7 +168,7 @@
 . endif
 .endif
 .if !defined(${X_}COMPILER_VERSION)
-${X_}COMPILER_VERSION!=echo "${_v:M[1-9].[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
+${X_}COMPILER_VERSION!=echo "${_v:M[1-9]*.[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
 .endif
 .undef _v
 .endif
--- share/mk/bsd.linker.mk.orig
+++ share/mk/bsd.linker.mk
@@ -59,7 +59,7 @@
 .if ${_ld_version:[1..2]} == "GNU ld"
 ${X_}LINKER_TYPE=	bfd
 ${X_}LINKER_FREEBSD_VERSION=	0
-_v=	${_ld_version:M[1-9].[0-9]*:[1]}
+_v=	${_ld_version:M[1-9]*.[0-9]*:[1]}
 .elif ${_ld_version:[1]} == "LLD"
 ${X_}LINKER_TYPE=	lld
 _v=	${_ld_version:[2]}
@@ -71,7 +71,7 @@
 ${X_}LINKER_TYPE=	bfd
 _v=	2.17.50
 .endif
-${X_}LINKER_VERSION!=	echo "${_v:M[1-9].[0-9]*}" | \
+${X_}LINKER_VERSION!=	echo "${_v:M[1-9]*.[0-9]*}" | \
 			  awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
 .undef _ld_version
 .undef _v
